import server from "../util/request.js";

export default {
    // 新增仓库
    addWarehouse(warehouse) {
        return server({
            url: '/warehouse/add',
            method: 'post',
            data: warehouse
        })
    },

    // 删除仓库
    deleteWarehouse(id) {
        return server({
            url: `/warehouse/delete/${id}`,
            method: 'delete'
        })
    },

    // 更新仓库
    updateWarehouse(warehouse) {
        return server({
            url: '/warehouse/update',
            method: 'put',
            data: warehouse
        })
    },

    // 根据ID查询仓库
    getWarehouseById(id) {
        return server({
            url: `/warehouse/get/${id}`,
            method: 'get'
        })
    },

    // 查询所有仓库
    getAllWarehouses() {
        return server({
            url: '/warehouse/getAll',
            method: 'get'
        })
    },

    // 模糊查询
    searchWarehouses(name, address) {
        return server({
            url: '/warehouse/search',
            method: 'get',
            params: {
                name,
                address
            }
        })
    },

    // 停用仓库
    disableWarehouse(warehouse) {
        return server({
            url: `/warehouse/disable/`,
            method: 'put',
            data: warehouse
        })
    }
}